package cn.itcast.order.config.ijpay.wxpay;

import com.ijpay.paypal.PayPalApiConfig;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author sxt
 * @version 1.0
 * @description wxpay 支付配置信息
 * @date 2024/4/26 18:28
 */
@SuppressWarnings({"LombokGetterMayBeUsed", "LombokSetterMayBeUsed"})
@Component
@ConfigurationProperties(prefix = "ijpay.wxpay")
public class WxPayApiConfigProperties implements InitializingBean, ApplicationContextAware {

    /**
     * wxpay配置集合
     */
    private List<WxPayBean> wxpayApiConfigs = new ArrayList<>();

    private ApplicationContext applicationContext;


    /**
     * 向缓存注入支付Api配置
     */
    @Override
    public void afterPropertiesSet() {
        if (applicationContext != null) {
            // todo
        }
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    public List<WxPayBean> getPayPalApiConfigs() {
        return wxpayApiConfigs;
    }

    public void setPayPalApiConfigs(List<WxPayBean> wxpayApiConfigs) {
        this.wxpayApiConfigs = wxpayApiConfigs;
    }
}
